<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--录入玩家数据--%>
<html>
    <head>
        <title>Title</title>
        <%
            String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
            /*
             * request.getScheme() : http
             * request.getServerName() : localhost
             * request.getServerPort() : 端口号
             * request.getContextPath() : /获取虚拟目录名(项目名jsp_framework)
             * */
        %>
        <base href="<%=basePath%>">
        <script src="js/jquery-3.3.1.js"></script>
        <script>
            $(function () {
                //使用ajax通信
                $("#enter_form").submit(function () {

                    $.post("${pageContext.request.contextPath}/communication/enterInfo",$(this).serialize(),function (data) {
                        if(data.flag){
                            alert("录入成功");
                        }else{
                            alert("录入信息失败");
                        }
                    })
                    return false;//阻止提交 (注意: 看似采用form通信 , 其实采用的是ajax)
                });
            });
        </script>
    </head>
    <body>

        <form id="enter_form">
            玩家名:<input type="text" name="playName"><br>
            攻击力:<input type="text" name="attack"><br>
            防御力:<input type="text" name="armor"><br>
            速度: <input type="text" name="speed"><br>
            职业: <input type="text" name="occupation"><br>
            技能: <input type="text" name="skill"><br>
            <input type="submit" value="提交"><br>
        </form>

        <em style="color: red">${enterInfoMsg}</em>

    </body>
</html>



































